<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <input type="button" value="AJAX请求">    
</body>
<script>
    var xhr=new XMLHttpRequest();
    // xhr.open('get','1.php?a=12&b=6',true);//第三个参数代表同步还是异步  true表示异步
    var formData=new FormData();
    formData.set('a',12)
    formData.set('b',6)
    xhr.open('get','1.php?a=12&b=6',true);
    // xhr.send();
    xhr.send(formData);
    
    xhr.onreadystatechange=function(){
        if(xhr.readyState==4){
            if((xhr.status>=200&&xhr.status<300)||xhr.status==304){
                alert(xhr.responseText);
            }else{
                alert('错了');
            }
        }
    }







</script>
</html>